package com.opeartion.controller;

import com.opeartion.pojo.Category;
import com.opeartion.service.RankService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author sanshi
 * @version 1.0
 * @data 2020/6/6-20:18
 */

@RestController
@RequestMapping("/rank")
public class RankController {
    @Autowired
    private RankService rankService;
    /**
     * 查询
     * @return
     */

    @GetMapping("/findCategory")
    public List<Category> findCategory() {
        return rankService.findCategory();
    }

    @GetMapping("/findCategoryOne")
    public List<Category> findCategory(String name) {
        return  rankService.findCategory(name);
    }

    /**
     * 添加
     * @param category
     */

    @PostMapping("/updateCategory")
    public void updateCategory(Category category) {
        rankService.updateCategory(category);
    }

    /**
     * 删除
     * @param id
     * @return
     */
    @DeleteMapping("/deleteCategory")
    public int deleteCategory(int id) {
        return rankService.deleteCategory(id);
    }

}
